package Thread;

import sun.applet.Main;

import java.util.Scanner;

public class demo1 {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        for(int i = 0;i<n;i++){
            System.out.println(Main.verify(sc.next()));
        }
    }

    /**
     校验字符串
     */
    public static String verify(String str){
        if(str.length()<3){    //字符串长度小于三时，直接返回
            return str;
        }
        String result = str.substring(0,2);
        if(str.charAt(0)==str.charAt(1)&&str.charAt(1)==str.charAt(2)){    //前三个字符是否相同
            result=result;
        }else{
            result += str.charAt(2);
        }
        int i=3;
        int index=3;
        int length = str.length();
        while(index<length){
            if((str.charAt(i-2)==str.charAt(i-1)&&str.charAt(i-1)==str.charAt(i))||(str.charAt(i-3)==str.charAt(i-2)&&str.charAt(i-1)==str.charAt(i))){
                str = str.substring(0,i) + str.substring(i+1);
                ++index;
            }else{
                result += str.charAt(i);
                ++index;
                ++i;
            }
        }

        return result;
    }
}
